<template>
  <el-container class="container">
    <el-aside :style="{width:isCollapse?'auto':'200px'}">
      <el-menu background-color="#001529" text-color="#fff"
               active-text-color="rgb(64, 158, 255)" active-background-color="blue"
               :collapse="isCollapse" :router="true">
        <div class="logo">
          <img src="../assets/images/logow.png" alt="logo">
          <!-- <span v-show="!isCollapse">冷轧板形遗传</span> -->
        </div>
        <template v-for="v in navs">
          <el-submenu v-if="v.children" :index="v.path" :route="{name:v.name}" :key="v.name" v-show="v.meta.isVisible">
            <template slot="title">
              <i :class="[v.meta.icon]"></i>
              <span>{{ v.meta.title }}</span>
            </template>
            <el-menu-item v-for="val in v.children" :index="val.path" :route="{name:val.name}" :key="val.name"
                          v-show="val.meta.isVisible">{{ val.meta.title }}
            </el-menu-item>
          </el-submenu>
          <el-menu-item v-else :index="v.path" :route="{name:v.name}" :key="v.name" v-show="v.meta.isVisible">
            <i :class="[v.meta.icon]"></i>
            <span slot="title">{{ v.meta.title }}</span>
          </el-menu-item>
        </template>
      </el-menu>
    </el-aside>
    <el-container>
      <el-header>
        <el-row>
          <el-col :span="1"><i class="el-icon-s-fold" @click="isCollapse=!isCollapse"></i></el-col>
          <el-col :span="15">
            <Breadcrumb></Breadcrumb>
          </el-col>
          <el-col :span="8">
            <el-menu class="el-menu-demo" mode="horizontal">
              <div class="logo" style="height: 55px;margin-right: 10px;display: inline-block;float: left;">
                <img src="../assets/images/iet_logo_2.png" alt="logo" class="logo" style="margin-top:10px;height:40px;">
              </div>
              <el-submenu index="2">
                <template slot="title">
                  <i class="el-icon-lcxguanliyuan"></i>
                  <span>{{ username }}</span>
                </template>
                <el-menu-item index="1-1">
                  <router-link :to="{name:'password'}" style="color:#909399;">
                    <i class="el-icon-lcxedit"></i>
                    修改密码
                  </router-link>
                </el-menu-item>
                <el-menu-item index="1-2" @click="loginout" class="fs12">
                  <i class="el-icon-lcxtuichudenglu"></i>
                  退出登录
                </el-menu-item>
              </el-submenu>
              <!-- <el-submenu index="3">
                <template slot="title">
                  <i class="el-icon-lcxbangzhuzhongxin"></i>
                  <span>帮助中心</span>
                </template>
                <el-menu-item index="2-1">
                  <el-link :underline="false" icon="el-icon-lcxbangzhuzhongxin">帮助中心</el-link>
                </el-menu-item>
                <el-menu-item index="2-2">
                  <el-link :underline="false" icon="el-icon-lcxinstruction">使用手册</el-link>
                </el-menu-item>
              </el-submenu> -->
            </el-menu>
          </el-col>
        </el-row>


      </el-header>
      <el-main>
        <router-view></router-view>
      </el-main>
    </el-container>
  </el-container>
</template>

<script>
// import api from "@/api";
import Breadcrumb from "@/components/Breadcrumb.vue";

export default {
  data() {
    return {
      isCollapse: false,
      navs: [],
      username: ""
    };
  },
  mounted() {
    this.navs = this.$router.options.routes[1].children;
    this.username = localStorage.getItem("username");
  },
  methods: {
    loginout() {
      localStorage.removeItem("token");
      localStorage.removeItem("username");
      this.$router.push('/')
      this.$message({
        message: "退出成功",
        type: "success"
      });
    }
  },
  components: {
    Breadcrumb
  }
};
</script>

<style>
#app {
  background: #f5f5f5;
}

.el-header {
  background: #fff;
  box-shadow: 0 2px 4px -2px rgba(0, 0, 0, .12), 0 4px 8px rgba(0, 0, 0, .08), 0 4px 16px 4px rgba(0, 0, 0, .04);
}

.el-main {
  background: #fff;
  box-shadow: 0 2px 4px -2px rgba(0, 0, 0, .12), 0 4px 8px rgba(0, 0, 0, .08), 0 4px 16px 4px rgba(0, 0, 0, .04);
  margin: 12px 20px 0 20px;
}

.el-dialog {
  background-color: #1f3293;
}

.el-dialog__header {
  padding: 0;
}

.el-dialog .el-table {
  background-color: #1A367A;
  color: #fff;
  //border: none;
  border: 1px solid #405790;
  box-shadow: 0 2px 4px -2px rgba(0, 0, 0, .12);
}

.el-dialog .el-table th {
  border: 1px solid #405790 !important;
  background-color: #1A367A;
  text-align: left;
  color: #ffffff;
}

.el-dialog .el-table tr {
  background-color: #1A367A;
}

/* 用来设置当前页面element全局table 鼠标移入某行时的背景色*/
.el-dialog .el-table--enable-row-hover .el-table__body tr:hover > td {
  background-color: #3366cc;
}

.el-dialog .el-table__body tr:hover > td {
  cursor: pointer;
  background-color: #3366cc !important;
}

.el-dialog .el-table__body tr.hover-row > td {
  cursor: pointer;
  background-color: #3366cc !important;
}

.el-dialog .el-table td {
  padding: 4px 0;
  border-color: #405790;
}

.el-dialog .el-table--border::after, .el-table--group::after, .el-table::before {
  background-color: transparent;
}
.public_box_title {
  font-size: 20px;
  font-weight: bold;
  letter-spacing: 2px;
  color: #ffffff;
  margin-bottom: 16px;
}

.container {
  height: 100%;
}

.container .el-main {
  overflow: hidden;
}

.container .el-aside {
  background: #001529;
}

.container .el-aside::-webkit-scrollbar {
  display: none;
}

.container .el-aside .logo {
  height: 60px;
  text-align: center;
  color: #fff;
  line-height: 60px;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.container .el-aside .logo span {
  display: inline-block;
  color: #fff;
  font-size: 20px;
}

.container .el-aside .logo img {
  display: inline-block;
  width: 100%;
}

.container .el-header {
  padding: 0;
  border-bottom: solid 1px #e6e6e6;
  box-shadow: 0 1px 4px rgba(0, 21, 41, 0.08);
}

.container .el-header .el-icon-s-fold {
  padding: 22px 24px;
  font-size: 20px;
  cursor: pointer;
  transition: all 0.3s, padding 0s;
}

.container .el-header .el-icon-s-fold:hover {
  background: rgba(0, 0, 0, 0.025);
}

.container .el-header .el-menu {
  float: right;
}

/* 头部导航 */
.el-submenu__title i {
  font-size: 18px;
  margin-right: 5px;
  text-align: center;
  vertical-align: middle;
  width: 24px;
}

.el-submenu__title span {
  font-size: 14px;
}

/* 消息 */
.message.el-menu-item {
  border-bottom: 1px solid #eee;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  font-size: 12px;
  height: 50px !important;
}

.message.el-menu-item .left {
  height: 36px;
  margin: 7px 10px 7px 0;
  width: 36px;
}

.message.el-menu-item .left i {
  background-color: #f2f2f2;
  border-radius: 50%;
  height: 100%;
  line-height: 36px;
  text-align: center;
  width: 100%;
}

.message.el-menu-item .right {
  height: 40px;
  line-height: 20px;
  margin: 5px 0;
}
</style>
